﻿using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;

namespace TracNghiemChonTruong.Class
{
    public class UserManager
    {
        public static UserManager CreateInstant()
        {
            return new UserManager();
        }
        public int InsertUpdate(string name, string email, string address = null, string phone = null, string school = null, string city = null)
        {
            var connectstring = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["htsConnectionString"].ToString();
            var ls = new List<SqlParameter>
                         {
                             new SqlParameter("@UserId", 0),
                             new SqlParameter("@Name", name),
                             new SqlParameter("@Email", email)
                         };

            var sqlparam = ls.ToArray();
            using (var helper = new TracNghiemChonTruong.Class.SqlHelper())
            {
                helper.ParamKeys = new List<string> {"@Name", "@Email", "@Address", "@Phone", "@School", "@City"};
                helper.ParamValues = new List<object> {name, email, address, phone, school, city};
                helper.ExecuteNonQuery("wp_InsertUpdateTblUser", CommandType.StoredProcedure);
            }

            return 0;
        }
    }
}